How to solve these challenges:
To be consistent with the filenames and paths run the commands on Ubuntu. Install it locally in a VM or at a cloud provider. Use my referral link below to create your account on DigitalOcean and youll get $100 in credit over 60 days: https://m.do.co/c/f1d4debf213f
Write your solution in a terminal and test it.
If your solution is not correct, then try to understand the error messages, watch the video again, rewrite the solution and test it again. Repeat this step until you get the correct solution.
Save the solution in a file for future reference or recap.
Challenge #1
Create a script that takes an argument and tests if it's a file or not.
Are you stuck? Do you want to see the solution for this challenge? Click here.
Challenge #2
Consider the solution from the previous challenge. Change it so that it tests if the script is run with exactly one argument.
Are you stuck? Do you want to see the solution for this challenge? Click here.
Challenge #3
Create a script that clears the contents of a text file which is the scripts argument.
Test that the argument is a file.
Are you stuck? Do you want to see the solution for this challenge? Click here.
Challenge #4
Create a script that drops the packets from an IP address given by the user.
Example: The command to drop the packets from 100.0.0.1 is: iptables -I INPUT -s 100.0.0.1 -j DROP
Run the script as root and test the connection to different IP addresses.
Are you stuck? Do you want to see the solution for this challenge? Click here.
Challenge #5
Change the solution from the previous challenge so that the IP address is given as the first argument of the script.
Test that the script is run with exactly one argument.
Are you stuck? Do you want to see the solution for this challenge? Click here.
Challenge #6
Develop a script that appends to a file the currently logged in users and the current date and time.
Are you stuck? Do you want to see the solution for this challenge? Click here.
Challenge #7
Create a script that prompts the user for a character.
If the character is Y, display "YES". If the character is N, display "NO". Use double quotes when displaying YES and NO. If the user enters any other character exit the script.
Are you stuck? Do you want to see the solution for this challenge? Click here.
Challenge #8
Change the previous script this way: If the character is Y or y display "YES". If the character is N or n display "NO". If the user enters any other character exit the script. Use the OR operator (||) for testing the lowercase y and n.
Are you stuck? Do you want to see the solution for this challenge? Click here.
Challenge #9
Create a script that takes exactly two arguments. The first argument is a shell command and the second argument is a string. The script will check if the string belongs to the output of the command.
Example: ./search_in_output.sh "ifconfig -a" "flags" will say if the string flags belongs to the output of ifconfig -a
Are you stuck? Do you want to see the solution for this challenge? Click here.